package com.liner.homework.first;


/**
 * 演示多态
 */
public class Test {
    public static void main(String[] args) {

       Master master = new Master();

        Animal[] animals = new Animal[3];
        animals[0] = new Dog("拉布拉多", 13, "灰色");
        animals[1] = new Fish("鲨鱼", 14, "蓝色");
        animals[2] = new Chick("小白", 12, "白色");


        for (Animal animal : animals) {
            animal.eat();
            animal.drink();
            master.feed(animal);

            if (animal instanceof Dog) {
                Dog dog = (Dog) animal;
                dog.lookHome();
            }
            if (animal instanceof Chick) {
                Chick chick = (Chick) animal;
                chick.layEggs();
            }
            if (animal instanceof Swim) {
                Swim swim = (Swim) animal;
                swim.swim();
            }
        }

    }


}
